<?php
$isReloadable = false;
require_once "../../../pers/inc.config.php";
require_once OVF_FS_WEB_ROOT.'/app/_inc/inc.session.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/funct.html.php';
require_once '../_inc/class.wfmModulo.php';
require_once '../_inc/class.wfmPagina.php';


$oMod = new wfmModulo(reqVarInt('id'));
if ($oMod->codModulo == "") {
	backOnErr("id.modulo '".reqVar('id')."' errato");
	exit;
}
$idModulo = $oMod->idModulo;
$codModulo = $oMod->codModulo;

$sSql = "SELECT r.* FROM wfm_rec_$codModulo r WHERE r.id_rec = ".reqVarInt('idr');
$objDB->query($sSql,'selRecX');
$aRec = $objDB->fetch('selRecX');
if (!$aRec) {
	backOnErr("id_rec '".reqVar('idr')."' errato");
	exit;
}

$oPag = new wfmPagina($oMod,0,'vis');
if ($oPag->codModulo == "") {
	backOnErr("id_pagina '".$aRec['id_pagina']."' errato");
	exit;
}

$oMod = &$oPag->oMod;
$oPag->prepMod($aRec);

$sCmdR = "";
$sCmdR .= cmdTorna();

testaHtml($oMod->titolo,'Visualizza registrazione',$msgPag,'wfma');
?>
<script type="text/javascript">
<!--
function submCmd(id,cmd) {
	document.frm1.X_id_comando.value = id;
	document.frm1.X_comando.value = cmd;
	document.frm1.azione.value = 'submCmd';
	document.frm1.submit();
}
function apriPopUpLog(idl){
  	url = "logPopUp.php?id=<?=$idModulo;?>&"+idl+"&xsn=<?=XSN?>";
	window.open(url, '_blank','width=730,height=300,top=50,left=50,resizable=yes,scrollbars=yes');
}
</script>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right">
			<? echo  $sCmdR;?>
      </td>
   </tr>
</table>
<?
echo getHtmlForm('frm1','',array('enctype'=>true));
echo getHtmlHidden('azione','...');
echo getHtmlHidden('id');
echo getHtmlHidden('idr');
echo getHtmlHidden('X_id_modulo',$oPag->idModulo);
echo getHtmlHidden('X_id_pagina',$oPag->idPagina);
echo getHtmlHidden('X_id_comando',0);
echo getHtmlHidden('X_comando','');
echo getHtmlHidden('xsn',XSN);

$sHtml = $oPag->getHtmlPagina('mod');
if (substr($sHtml,0,10)=='@@include=') {
	include substr($sHtml,10);
} else {
	echo $sHtml;
}
?>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right">
         <? echo  $sCmdR;?>
      </td>
   </tr>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="tit1" align="center" colspan='4'>
         Cronologia
      </td>
   </tr>
   <tr>
      <td class="lab1" align="center">&nbsp;</td>
      <td class="lab1" align="center">Data/ora</td>
      <td class="lab1" align="center">Stato</td>
      <td class="lab1" align="center">Operatore</td>
   </tr>
<?php 
$sSql = "SELECT l.* "
	." FROM wfm_rec_".$codModulo."_log l "
	." WHERE l.id_rec = ".reqVar('idr')
	." ORDER BY l.data_ora_mod ";
$objDB->exec($sSql);
$b1 = false;
while($aLog = $objDB->fetch()) {
?>
   <tr>
      <td class="txt1" align="center">
      	<a href="#" class='txt1'
      		title="ripistina questa situazione">
      		<img src="../../_img/ripr.png" border='0'/>	
      	</a>
      </td>
      <td class="txt1" align="center">
<?php 
	if ($b1) {
		echo "<a href=\"javascript:apriPopUpLog('idl=".$aLog['id_log']."');\" class='txt1' "
      		."title=\"visualizza dati modificati\">";
	}
   echo date("Y-m-d H:i:s",strtotime($aLog['data_ora_mod']));
   if ($b1) {
   	echo "</a>";
   }
   $b1 = true;
?>
      </td>
      <td class="txt1" align="left">
      	<?php echo $aLog['stato']." - ".$oMod->getStatoDes($aLog['stato']);?>
      </td>
      <td class="txt1" align="left">
			<?php echo getUteDes($aLog['id_utente_mod']);?>
		</td>
   </tr>
<?php 
}
?>
   <tr>
      <td class="txt1" style="text-align:center;font-weight:bold;" >
      	&nbsp;
      </td>
      <td class="txt1" style="text-align:center;font-weight:bold;" >
<?php 
	if ($b1) {
		echo "<a href=\"javascript:apriPopUpLog('idr=".reqVar('idr')."');\" class='txt1' "
      		."title=\"visualizza dati modificati\">";
	}
   echo date("Y-m-d H:i:s",strtotime($aLog['data_ora_mod']));
   if ($b1) {
   	echo "</a>";
   }
?>
      </td>
      <td class="txt1" align="left" style="text-align:left;font-weight:bold;" >
      	<?php echo reqVar('A_stato')." - ".$oMod->getStatoDes(reqVar('A_stato'));?>
      </td>
      <td class="txt1" style="text-align:left;font-weight:bold;" >
			<?php echo getUteDes(reqVar('A_id_utente_mod'));?>
		</td>
   </tr>
</table>
<?
echo "</form>\n";
codaHtml();
exit();
